package com.tencent.wepay.protocol.mchpay.request;

import java.io.Serializable;

import com.tencent.wepay.annotation.NotBlank;
import com.tencent.wepay.annotation.NotNull;
import com.tencent.wepay.annotation.Range;
import com.tencent.wepay.annotation.SignIgnore;
import com.tencent.wepay.protocol.domain.XStreamDomain;
import com.tencent.wepay.util.IpUtil;
import com.tencent.wepay.util.RandomUtil;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
@XStreamAlias("xml")
public class TransferRequest extends XStreamDomain implements Serializable{
	private static final long serialVersionUID = -1359995818440540317L;
	public enum CheckNameENUM{
		NO_CHECK,FORCE_CHECK,OPTION_CHECK;
	}
	@NotBlank(desc="公众号或应用APPID不能为空")
	@XStreamAlias("mch_appid")
	private String appid;
	@NotBlank(desc="商户号不能为空")
	@XStreamAlias("mchid")
	private String mchId;
	@XStreamAlias("device_info")
	private String deviceInfo;
	@XStreamAlias("nonce_str")
	private String nonceStr=RandomUtil.uuid();
	@XStreamAlias("sign")
	@SignIgnore
	private String sign;
	@NotBlank("商家交易订单号不能为空")
	@XStreamAlias("partner_trade_no")
	private String tradeNo;
	@NotBlank(desc="用户不能为空")
	@XStreamAlias("openid")
	private String openid;
	@XStreamAlias("check_name")
	private String checkName;
	@XStreamAlias("re_user_name")
	@NotBlank(relate="checkName",desc="用户真实姓名不能为空",value={"FORCE_CHECK","OPTION_CHECK"})
	private String realName;
	@Range(min=100,desc="金额必须大于{0}")
	@NotNull(desc="金额不能为空")
	@XStreamAlias("amount")
	private Integer amount;
	@XStreamAlias("desc")
	@NotBlank("支付描述不能为空")
	private String desc;
	@XStreamAlias("spbill_create_ip")
	private String ip=IpUtil.getLocalIp();
	@XStreamOmitField
	@SignIgnore
	@NotBlank(desc="支付密钥不能为空")
	private String key;
	public TransferRequest() {
		// TODO Auto-generated constructor stub
	}
	public TransferRequest(String tradeNo,String openid,int amount,String desc){
		this.tradeNo=tradeNo;
		this.openid=openid;
		this.amount=amount;
		this.desc=desc;
	}
	public String getAppid() {
		return appid;
	}
	public void setAppid(String appid) {
		this.appid = appid;
	}
	public String getMchId() {
		return mchId;
	}
	public void setMchId(String mchId) {
		this.mchId = mchId;
	}
	public String getDeviceInfo() {
		return deviceInfo;
	}
	public void setDeviceInfo(String deviceInfo) {
		this.deviceInfo = deviceInfo;
	}
	public String getNonceStr() {
		return nonceStr;
	}
	public void setNonceStr(String nonceStr) {
		this.nonceStr = nonceStr;
	}
	public String getSign() {
		return sign;
	}
	public void setSign(String sign) {
		this.sign = sign;
	}
	public String getTradeNo() {
		return tradeNo;
	}
	public void setTradeNo(String tradeNo) {
		this.tradeNo = tradeNo;
	}
	public String getOpenid() {
		return openid;
	}
	public void setOpenid(String openid) {
		this.openid = openid;
	}
	public String getCheckName() {
		return checkName;
	}
	public void setCheckName(String checkName) {
		this.checkName = checkName;
	}
	public String getRealName() {
		return realName;
	}
	public void setRealName(String realName) {
		this.realName = realName;
	}
	public Integer getAmount() {
		return amount;
	}
	public void setAmount(Integer amount) {
		this.amount = amount;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	public String getKey() {
		return key;
	}
	public void setKey(String key) {
		this.key = key;
	}
	@Override
	public String toXML() {
		setSign(toSign(key));
		return super.toXML();
	}
}
